-
Notifications
You must be signed in to change notification settings - Fork 11
git init
compatibility, Git.version()
#491
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Reviewer's GuideThis pull request introduces a vendorized version parsing module to enable uniform Git version comparison and improve Class Diagram for Structure Types (_structures.py)classDiagram
class InfinityType {
+__repr__() str
+__hash__() int
+__lt__(other: object) bool
+__le__(other: object) bool
+__eq__(other: object) bool
+__gt__(other: object) bool
+__ge__(other: object) bool
+__neg__() NegativeInfinityType
}
class NegativeInfinityType {
+__repr__() str
+__hash__() int
+__lt__(other: object) bool
+__le__(other: object) bool
+__eq__(other: object) bool
+__gt__(other: object) bool
+__ge__(other: object) bool
+__neg__() InfinityType
}
note "Defines Infinity and NegativeInfinity types and instances (Infinity, NegativeInfinity) used in version comparison logic."
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #491 +/- ##
==========================================
+ Coverage 54.09% 56.84% +2.75%
==========================================
Files 40 42 +2
Lines 3627 4030 +403
Branches 793 824 +31
==========================================
+ Hits 1962 2291 +329
- Misses 1314 1365 +51
- Partials 351 374 +23 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @tony - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
When stuck in debugging loops: | ||
|
||
1. **Pause and acknowledge the loop** | ||
2. **Minimize to MVP**: Remove all debugging cruft and experimental code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (typo): Potential Markdown formatting typo.
There's an extra asterisk in MVP**:
. For proper bolding use **MVP**:
.
2. **Minimize to MVP**: Remove all debugging cruft and experimental code | |
2. Minimize to **MVP**: Remove all debugging cruft and experimental code |
"""Take a string like abc.1.twelve and turns it into ("abc", 1, "twelve").""" | ||
if local is not None: | ||
return tuple( | ||
part.lower() if not part.isdigit() else int(part) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (code-quality): Swap if/else branches of if expression to remove negation (swap-if-expression
)
part.lower() if not part.isdigit() else int(part) | |
int(part) if part.isdigit() else part.lower() |
Explanation
Negated conditions are more difficult to read than positive ones, so it is bestto avoid them where we can. By swapping the
if
and else
conditions around wecan invert the condition and make it positive.
if not letter and number: | ||
# We assume if we are given a number, but we are not given a letter | ||
# then this is using the implicit post release syntax (e.g. 1.0-1) | ||
letter = "post" | ||
|
||
return letter, int(number) | ||
|
||
return None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (code-quality): We've found these issues:
- Remove redundant conditional (
remove-redundant-if
) - Lift code into else after jump in control flow (
reintroduce-else
) - Replace if statement with if expression (
assign-if-exp
) - Inline variable that is only used once (
inline-variable
)
if not letter and number: | |
# We assume if we are given a number, but we are not given a letter | |
# then this is using the implicit post release syntax (e.g. 1.0-1) | |
letter = "post" | |
return letter, int(number) | |
return None | |
return ("post", int(number)) if number else None |
pre_ = pre | ||
|
||
# Versions without a post segment should sort before those with one. | ||
if post is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (code-quality): Replace if statement with if expression [×2] (assign-if-exp
)
0698864
to
544534a
Compare
dc721be
to
56e43a6
Compare
- Add GitVersionInfo dataclass to provide structured git version output - Update version() method to return raw string output - Add build_options() method that returns a GitVersionInfo instance - Fix doctests in vendored version module - Use internal vendor.version module instead of external packaging
…on compatibility why: Fix compatibility with Git 2.43.0+ which has stricter init behavior what: - Replace raw run() command with Git.init() method - Add initial_branch parameter with env var and default fallback - Try --initial-branch flag first, fall back for older Git versions - Add DEFAULT_GIT_INITIAL_BRANCH constant configurable via env var This ensures Git repository creation works across all Git versions by leveraging libvcs's own Git command abstraction layer.
…atibility why: Ensure Git init compatibility fix works across all scenarios what: - Test basic and bare repository creation - Test Git version compatibility with mocked old/new Git - Test configuration hierarchy (param > env > default) - Test error handling for permission errors - Test post-init callback execution - Add integration test with real Git command Tests use monkeypatch to simulate different Git versions and ensure the fallback mechanism works correctly for older Git versions that don't support --initial-branch.
why: Complete the migration from master to main as default branch what: - Update test_get_current_remote_name to checkout 'main' instead of 'master' - Update Git.rebase doctests to expect 'main' in output - Update Git.rev_list doctest to expect 'main' in commit output - All tests now pass with the new default branch configuration
43cac24
to
7a5d084
Compare
Problem
git init
compatibility issuesgit --version
Details
Summary by Sourcery
Improve git compatibility by introducing internal version parsing utilities and updating documentation with project standards and workflows.
New Features:
Enhancements:
Documentation: